﻿using System;
using DDDNorthWind.Core.Domain.ValueObject;

namespace DDDNorthWind.AC.Products.Domain.ValueObject
{
    public class ProductPrice:ValueObject<ProductPrice>
    {
        public decimal SuggestedRetailPrice { get; set; }

        public DateTime StartDate { get; set; }

        public DateTime EndDate { get; set; }



        #region [equals]
        public override bool Equals(object obj)
        {
            return base.Equals(obj);
        }


        public override bool Equals(ProductPrice other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.SuggestedRetailPrice == SuggestedRetailPrice && other.StartDate.Equals(StartDate) && other.EndDate.Equals(EndDate);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = SuggestedRetailPrice.GetHashCode();
                result = (result * 397) ^ StartDate.GetHashCode();
                result = (result * 397) ^ EndDate.GetHashCode();
                return result;
            }
        }

        public static bool operator ==(ProductPrice left, ProductPrice right)
        {
            return Equals(left, right);
        }

        public static bool operator !=(ProductPrice left, ProductPrice right)
        {
            return !Equals(left, right);
        } 
        #endregion
    }
}